package ast

import "gitcode.com/deyiyangyang/gascheme/tok"

type Node interface {
	TokenLiteral() string
}

// StringLiteral represents a string literal expression
// such as "hello world" in Scheme
type StringLiteral struct {
	Token tok.Token
	Value string
}

// TokenLiteral returns the token's lexeme
func (sl *StringLiteral) TokenLiteral() string {
	return sl.Token.Lexeme
}

// BooleanLiteral represents a boolean literal expression
// such as #t and #f in Scheme
type BooleanLiteral struct {
	Token tok.Token
	Value bool
}

// TokenLiteral returns the token's lexeme
func (bl *BooleanLiteral) TokenLiteral() string {
	return bl.Token.Lexeme
}

// CharacterLiteral represents a character literal expression
// such as #\a, #\A, #\space, #\newline in Scheme
type CharacterLiteral struct {
	Token tok.Token
	Value rune
}

// TokenLiteral returns the token's lexeme
func (cl *CharacterLiteral) TokenLiteral() string {
	return cl.Token.Lexeme
}

// Expression represents an expression node
type Expression interface {
	Node
}

// IntegerLiteral represents an integer literal expression
type IntegerLiteral struct {
	Token tok.Token
	Value int64
}

// TokenLiteral returns the token's lexeme
func (il *IntegerLiteral) TokenLiteral() string {
	return il.Token.Lexeme
}

// RationalLiteral represents a rational number literal expression
type RationalLiteral struct {
	Token tok.Token
	Numerator   int64
	Denominator int64
}

// TokenLiteral returns the token's lexeme
func (rl *RationalLiteral) TokenLiteral() string {
	return rl.Token.Lexeme
}

// RealLiteral represents a real number literal expression
type RealLiteral struct {
	Token tok.Token
	Value float64
}

// TokenLiteral returns the token's lexeme
func (rl *RealLiteral) TokenLiteral() string {
	return rl.Token.Lexeme
}

// SymbolLiteral represents a symbol (identifier or operator)
type SymbolLiteral struct {
	Token tok.Token
	Value string
}

// TokenLiteral returns the token's lexeme
func (sl *SymbolLiteral) TokenLiteral() string {
	return sl.Token.Lexeme
}

// ListExpression represents a list expression in Scheme
type ListExpression struct {
	Token    tok.Token // the '(' token
	Elements []Expression
}

// TokenLiteral returns the token's lexeme
func (le *ListExpression) TokenLiteral() string {
	return le.Token.Lexeme
}
